package com.aaa.whj.service.impl;


/**
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
*/


import com.aaa.whj.dao.TabReturnDao;
import com.aaa.whj.entity.TabReturn;
import com.aaa.whj.service.TabReturnService;


import com.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * (TabReturn)表服务实现类
 *
 * @author makejava
 * @since 2023-05-12 11:29:26
 */
//@Service("tabReturnService")
public class TabReturnServiceImpl implements TabReturnService {
/**
    @Resource
    private TabReturnDao tabReturnDao;
*/
    SqlSession session= SqlSessionFactoryUtil.getSession();
    TabReturnDao tabReturnDao= session.getMapper(TabReturnDao.class);

    /**
     * 通过ID查询单条数据
     *
     * @param reId 主键
     * @return 实例对象
     */
    @Override
    public TabReturn queryById(Integer reId) {
        return this.tabReturnDao.queryById(reId);
    }

    /**
     * 分页查询
     *
     * @param tabReturn 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
     /**
    @Override
    public Page<TabReturn> queryByPage(TabReturn tabReturn, PageRequest pageRequest) {
        long total = this.tabReturnDao.count(tabReturn);
        return new PageImpl<>(this.tabReturnDao.queryAllByLimit(tabReturn, pageRequest), pageRequest, total);
    }*/

    /**
     * 新增数据
     *
     * @param tabReturn 实例对象
     * @return 实例对象
     */
    @Override
    public TabReturn insert(TabReturn tabReturn) {
        this.tabReturnDao.insert(tabReturn);
        return tabReturn;
    }

    /**
     * 修改数据
     *
     * @param tabReturn 实例对象
     * @return 实例对象
     */
    @Override
    public TabReturn update(TabReturn tabReturn) {
        this.tabReturnDao.update(tabReturn);
        return this.queryById(tabReturn.getRe_id());
    }

    /**
     * 通过主键删除数据
     *
     * @param reId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer reId) {
        return this.tabReturnDao.deleteById(reId) > 0;
    }

    @Override
    public List<TabReturn> queryAll(String page, String limit) {
        return this.tabReturnDao.queryAll();
    }

    @Override
    public long count1(TabReturn tabReturn) {
        return this.tabReturnDao.count(tabReturn);
    }


}
